import { defineStore } from 'pinia'
import { useStorage, useStorageType } from '@/utils'

export const useI18nStore = defineStore('i18n', {
  state: () => ({
    locale: useStorage.getItem('locale', useStorageType.sessionStorage) || 'zh'
  }),
  actions: {
    setLocaleAction(locale: string) {
      this.locale = locale
      useStorage.setItem('locale', locale, useStorageType.sessionStorage)
    }
  }
  /* persist: {
    key: 'i18n',
    storage: window.sessionStorage,
    paths: ['locale']
  } */
})
